﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ERP_CargoManage.aspx.cs" Inherits="CRM_Manager_ERP_CargoManage" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>商品目录</title>
    <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../JavaScript/Common.js"></script>
    <script type="text/javascript">
        function SelectedCargo() {
            var record = GridPanel1.selModel.getSelected();
            Ext.getCmp('SelectedCargoId').setValue(record.data.CargoId);
            GridPanel2.reload();
        }
        function GetStateName(value) {
            switch (value) {
                case 0:
                    return "无效";
                case 1:
                    return "有效";
                default:
                    return "无效";
            }
        }
        function GetCargoState(a,b,c) {
            if (c.data.DelState == -1)
                return "无效";
            if (c.data.DelState == 1)
                return "已删除";
            if (c.data.DelState == 0 && c.data.State == 0)
                return "无效";
            if (c.data.DelState == 0 && c.data.State == 1)
                return "有效";
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled" />
    <ext:Store ID="Store1" runat="server" AutoLoad="true" OnRefreshData="OnData_Refresh" RemoteSort="true">
        <Proxy>
            <ext:PageProxy>
            </ext:PageProxy>
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="CargoId">
                <Fields>
                    <ext:RecordField Name="CargoId" />
                    <ext:RecordField Name="CargoName" />
                    <ext:RecordField Name="Spell" />
                    <ext:RecordField Name="ByName" />
                    <ext:RecordField Name="CargoCode" />
                    <ext:RecordField Name="Spec" />
                    <ext:RecordField Name="Version" />
                    <ext:RecordField Name="ProduceName" />
                    <ext:RecordField Name="TypeId" />
                    <ext:RecordField Name="UseId" />
                    <ext:RecordField Name="Area" />
                    <ext:RecordField Name="Unit" />
                    <ext:RecordField Name="IsImported" />
                    <ext:RecordField Name="Pic" />
                    <ext:RecordField Name="InUser" />
                    <ext:RecordField Name="InDate" />
                    <ext:RecordField Name="DelUser" />
                    <ext:RecordField Name="DelDate" />
                    <ext:RecordField Name="DelState" />
                    <ext:RecordField Name="Type_Name" />
                    <ext:RecordField Name="Use_NAME" />
                    <ext:RecordField Name="Inuser_Name" />
                    <ext:RecordField Name="Deluser_Name" />
                    <ext:RecordField Name="IsImport" />
                    <ext:RecordField Name="State" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="Store3" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="Use_ID">
                <Fields>
                    <ext:RecordField Name="Use_ID" />
                    <ext:RecordField Name="Use_NAME" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server">
        <Content>
            <ext:RowLayout ID="RowLayout1" runat="server">
                <Rows>
                    <ext:LayoutRow RowHeight="0.7">
                        <ext:Panel ID="Panel4" runat="server" Layout="FitLayout" Border="false">
                            <Content>
                                <ext:RowLayout ID="RowLayout2" runat="server">
                                    <Rows>
                                        <ext:LayoutRow>
                                            <ext:Panel ID="Panel3" runat="server" Layout="FitLayout" Border="false" Height="150" Padding="5">
                                                <TopBar>
                                                    <ext:Toolbar ID="Toolbar1" runat="server">
                                                        <Items>
                                                            <ext:Button ID="extBtn_Refresh" runat="server" Text="刷新" Icon="ArrowRefresh">
                                                                <DirectEvents>
                                                                    <Click OnEvent="extBtn_Refresh_Click">
                                                                        <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{GridPanel1}" />
                                                                    </Click>
                                                                </DirectEvents>
                                                            </ext:Button>
                                                            <ext:Button ID="extBtn_Add" runat="server" Text="新增" Icon="Add">
                                                            </ext:Button>
                                                             <ext:Button ID="extBtn_Edit" runat="server" Text="修改" Icon="GroupEdit">
                                                            </ext:Button>
                                                            <ext:Button ID="extBtn_Delete" runat="server" Text="删除" Icon="Delete">
                                                                <DirectEvents>
                                                                    <Click OnEvent="extBtn_Delete_Click">
                                                                    </Click>
                                                                </DirectEvents>
                                                            </ext:Button>
                                                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                                            <%--<ext:Button ID="extBtn_Export" runat="server" Text="导出" Icon="PageWhitePut" Hidden="true">
                                                                <DirectEvents>
                                                                    <Click OnEvent="ExtBtn_Export_Click">
                                                                        <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{Viewport1}" Msg="正在加载..." />
                                                                    </Click>
                                                                </DirectEvents>
                                                            </ext:Button>--%>
                                                        </Items>
                                                    </ext:Toolbar>
                                                </TopBar>
                                                <Content>
                                                    <ext:FieldSet ID="FieldSet1" runat="server" Title="查询条件" Height="150">
                                                        <Items>
                                                            <ext:FormPanel ID="searchForm" runat="server" Height="140" Border="false">
                                                                <Content>
                                                                    <ext:ColumnLayout ID="ColumnLayout2" runat="server" FitHeight="true">
                                                                        <Columns>
                                                                            <ext:LayoutColumn ColumnWidth="0.33">
                                                                                <ext:Panel ID="Pane2l5" runat="server" Border="false" Height="80">
                                                                                    <Content>
                                                                                        <ext:FormLayout ID="FormLayout1" runat="server">
                                                                                            <Anchors>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_CargoName" LabelStyle=" text-align:right; " FieldLabel="商品名称">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_Spec" LabelStyle=" text-align:right; " FieldLabel="规格">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_Area" LabelStyle=" text-align:right; " FieldLabel="产地">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                            </Anchors>
                                                                                        </ext:FormLayout>
                                                                                    </Content>
                                                                                </ext:Panel>
                                                                            </ext:LayoutColumn>
                                                                            <ext:LayoutColumn ColumnWidth="0.33">
                                                                                <ext:Panel ID="Panel6" runat="server" Border="false" Height="140">
                                                                                    <Content>
                                                                                        <ext:FormLayout ID="FormLayout2" runat="server">
                                                                                            <Anchors>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_ByName" LabelStyle=" text-align:right; " FieldLabel="别名">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_Version" FieldLabel="型号" LabelStyle=" text-align:right; ">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:ComboBox ID="extcomb_Use" StyleSpec="width:70%" runat="server" FieldLabel="商品用途"   TabIndex="1"
                                                                                                        LabelStyle=" text-align:right; " Editable="false" ValueField="Use_ID" DisplayField="Use_NAME"
                                                                                                        StoreID="Store3">
                                                                                                    </ext:ComboBox>
                                                                                                </ext:Anchor>
                                                                                            </Anchors>
                                                                                        </ext:FormLayout>
                                                                                    </Content>
                                                                                </ext:Panel>
                                                                            </ext:LayoutColumn>
                                                                            <ext:LayoutColumn ColumnWidth="0.33">
                                                                                <ext:Panel ID="Panel2" runat="server" Border="false" Height="140">
                                                                                    <Content>
                                                                                        <ext:FormLayout ID="FormLayout3" runat="server">
                                                                                            <Anchors>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_CargoCode" LabelStyle=" text-align:right; " FieldLabel="商品代码">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:TextField runat="server" ID="exttxtf_ProduceName" LabelStyle=" text-align:right; " FieldLabel="生产厂家">
                                                                                                    </ext:TextField>
                                                                                                </ext:Anchor>
                                                                                                <ext:Anchor Horizontal="95%">
                                                                                                    <ext:Panel runat="server" ID="Panel132" Border="false">
                                                                                                        <Content>
                                                                                                            <table width="100%">
                                                                                                                <tr style="width: 100%">
                                                                                                                    <td align="right">
                                                                                                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                                                                    </td>
                                                                                                                    <td align="right" width="50%">
                                                                                                                        <ext:Button ID="extBtn_Search" runat="server" Text="查询" Icon="Find">
                                                                                                                            <DirectEvents>
                                                                                                                                <Click OnEvent="OnBtnSearchClick">
                                                                                                                                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{GridPanel1}" Msg="正在加载..." />
                                                                                                                                </Click>
                                                                                                                            </DirectEvents>
                                                                                                                        </ext:Button>
                                                                                                                    </td>
                                                                                                                    <td align="right">
                                                                                                                        &nbsp;&nbsp;&nbsp;&nbsp;
                                                                                                                    </td>
                                                                                                                    <td align="left" width="50%">
                                                                                                                        <ext:Button ID="extBtn_Clear" runat="server" Text="清空" Icon="BasketDelete">
                                                                                                                            <Listeners>
                                                                                                                                <Click Handler="searchForm.reset();" />
                                                                                                                            </Listeners>
                                                                                                                        </ext:Button>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </table>
                                                                                                        </Content>
                                                                                                    </ext:Panel>
                                                                                                </ext:Anchor>
                                                                                            </Anchors>
                                                                                        </ext:FormLayout>
                                                                                    </Content>
                                                                                </ext:Panel>
                                                                            </ext:LayoutColumn>
                                                                        </Columns>
                                                                    </ext:ColumnLayout>
                                                                </Content>
                                                            </ext:FormPanel>
                                                        </Items>
                                                    </ext:FieldSet>
                                                </Content>
                                            </ext:Panel>
                                        </ext:LayoutRow>
                                        <ext:LayoutRow RowHeight="1">
                                            <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" AutoScroll="true" Layout="FitLayout" AutoExpandColumn="Area" BodyStyle=" border-width:0 0 0 0">
                                                <ColumnModel ID="ColumnModel1" runat="server">
                                                    <Columns>
                                                        <ext:RowNumbererColumn Header="序号" Width="35" />
                                                        <ext:Column Header="CargoId" DataIndex="CargoId" Hidden="true">
                                                        </ext:Column>
                                                        <ext:Column Header="商品名称" DataIndex="CargoName" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="商品别名" DataIndex="ByName" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="商品码" DataIndex="CargoCode" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="规格" DataIndex="Spec" Width="120">
                                                        </ext:Column>
                                                        <ext:Column Header="型号" DataIndex="Version" Width="120">
                                                        </ext:Column>
                                                        <ext:Column Header="生产厂家" DataIndex="ProduceName" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="产地" DataIndex="Area">
                                                        </ext:Column>
                                                        <ext:Column Header="单位" DataIndex="Unit" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="来源" DataIndex="IsImport" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="用途" DataIndex="Type_Name" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="分类" DataIndex="Use_NAME" Width="100">
                                                        </ext:Column>
                                                        <ext:Column Header="状态" DataIndex="State" Width="80">
                                                            <Renderer Fn="GetCargoState" />
                                                        </ext:Column>
                                                    </Columns>
                                                </ColumnModel>
                                                <Listeners>
                                                    <RowClick Fn="SelectedCargo" />
                                                </Listeners>
                                                <SelectionModel>
                                                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                                    </ext:RowSelectionModel>
                                                </SelectionModel>
                                                <BottomBar>
                                                    <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="20" StoreID="Store1"
                                                        Height="25" DisplayInfo="true" DisplayMsg="显示{0} - {1},共{2}条" EmptyMsg="没有可显示的记录" />
                                                </BottomBar>
                                            </ext:GridPanel>
                                        </ext:LayoutRow>
                                    </Rows>
                                </ext:RowLayout>
                            </Content>
                        </ext:Panel>
                    </ext:LayoutRow>
                    <ext:LayoutRow RowHeight="0.3">
                        <ext:Panel ID="Panel1" runat="server" Layout="Fit" Cls="tool-form" Border="false">
                            <Content>
                                <ext:GridPanel ID="GridPanel2" runat="server" AutoScroll="true" Border="false" >
                                    <ColumnModel ID="ColumnModel2" runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn Header="序号" Width="35" />
                                            <ext:Column Header="DetailId" DataIndex="DetailId" Hidden="true">
                                            </ext:Column>
                                            <ext:Column Header="供应商" DataIndex="SupplyName" Width="100">
                                            </ext:Column>
                                            <ext:Column Header="状态" DataIndex="State" Width="60">
                                                <Renderer Fn="GetStateName" />
                                            </ext:Column>
                                            <ext:Column Header="供应单价" DataIndex="Supplyprice" Width="80">
                                            </ext:Column>
                                            <ext:Column Header="录入人" DataIndex="InuserNAME" Width="60">
                                            </ext:Column>
                                            <ext:DateColumn Header="录入时间" DataIndex="InDate" Width="80" Format="Y-m-d H:i:s">
                                            </ext:DateColumn>
                                            <ext:Column Header="停用人" DataIndex="DELNAME" Width="100">
                                            </ext:Column>
                                            <ext:DateColumn Header="停用时间" DataIndex="DelState" Width="80" Format="Y-m-d H:i:s">
                                            </ext:DateColumn>
                                        </Columns>
                                    </ColumnModel>
                                    <Store>
                                        <ext:Store ID="Store2" runat="server"  AutoLoad="false" OnRefreshData="CargoDetail_Refresh">
                                            <Proxy>
                                                <ext:PageProxy>
                                                </ext:PageProxy>
                                            </Proxy>
                                            <Reader>
                                                <ext:JsonReader IDProperty="DetailId">
                                                    <Fields>
                                                        <ext:RecordField Name="DetailId" />
                                                        <ext:RecordField Name="CargoId" />
                                                        <ext:RecordField Name="SupplyId" />
                                                        <ext:RecordField Name="SupplyName" />
                                                        <ext:RecordField Name="Supplyprice" />
                                                        <ext:RecordField Name="State" />
                                                        <ext:RecordField Name="Remark"/>
                                                        <ext:RecordField Name="Inuser" />
                                                        <ext:RecordField Name="InuserNAME" />
                                                        <ext:RecordField Name="InDate" Type="Date"/>
                                                        <ext:RecordField Name="DelUser" />
                                                        <ext:RecordField Name="DELNAME" />
                                                        <ext:RecordField Name="DelDate" Type="Date"/>
                                                        <ext:RecordField Name="DelState" />
                                                    </Fields>
                                                </ext:JsonReader>
                                            </Reader>
                                        </ext:Store>
                                    </Store>
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionModel2" runat="server">
                                        </ext:RowSelectionModel>
                                    </SelectionModel>
                                </ext:GridPanel>
                            </Content>
                        </ext:Panel>
                    </ext:LayoutRow>
                </Rows>
            </ext:RowLayout>
        </Content>
    </ext:Viewport>
    <ext:Hidden runat="server" ID="SelectedCargoId">
    </ext:Hidden>
    </form>
</body>
</html>
